/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ronin.model;

import com.ronin.model.constant.DurumEnum;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author esimsek
 */
@Entity
@Table(name = "hizmet_kategori")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HizmetKategori.findAll", query = "SELECT h FROM HizmetKategori h"),
    @NamedQuery(name = "HizmetKategori.findById", query = "SELECT h FROM HizmetKategori h WHERE h.id = :id"),
    @NamedQuery(name = "HizmetKategori.findByFirmaId", query = "SELECT h FROM HizmetKategori h WHERE h.firma.id = :firmaId"),
    @NamedQuery(name = "HizmetKategori.findBySubeId", query = "SELECT h FROM HizmetKategori h WHERE h.sube.id = :subeId"),
    @NamedQuery(name = "HizmetKategori.findByAd", query = "SELECT h FROM HizmetKategori h WHERE h.ad = :ad")})
public class HizmetKategori implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @JoinColumn(name = "firma_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Firma firma;
    @JoinColumn(name = "sube_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Sube sube;
    @Basic(optional = false)
    @Column(name = "ad")
    private String ad;
    @OneToMany(cascade = CascadeType.REFRESH, mappedBy = "hizmetKategori")
    private List<Hizmet> hizmetList;
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "durum_id")
    private DurumEnum durum;

    public HizmetKategori() {
    }

    public HizmetKategori(Long id) {
        this.id = id;
    }

    public HizmetKategori(Long id, Firma firma, Sube sube, String ad,DurumEnum durum) {
        this.id = id;
        this.firma = firma;
        this.sube = sube;
        this.ad = ad;
        this.durum = durum;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAd() {
        return ad;
    }

    public void setAd(String ad) {
        this.ad = ad;
    }

    @XmlTransient
    public List<Hizmet> getHizmetList() {
        return hizmetList;
    }

    public void setHizmetList(List<Hizmet> hizmetList) {
        this.hizmetList = hizmetList;
    }

    public Firma getFirma() {
        return firma;
    }

    public void setFirma(Firma firma) {
        this.firma = firma;
    }

    public Sube getSube() {
        return sube;
    }

    public void setSube(Sube sube) {
        this.sube = sube;
    }

    public DurumEnum getDurum() {
        return durum;
    }

    public void setDurum(DurumEnum durum) {
        this.durum = durum;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HizmetKategori)) {
            return false;
        }
        HizmetKategori other = (HizmetKategori) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ronin.model.HizmetKategori[ id=" + id + " ]";
    }
    
}
